<template>
  <el-link id="to_top" type="primary" :underline="false" @click="toTop">
    返<br>回<br>顶<br>部
  </el-link>
</template>

<script>
export default {
  name: "to-top",
  methods: {
    toTop() {
      if (window.scrollY > 0) {
        window.scroll({top: 0, behavior: 'smooth'})
      }
    }
  }
}
</script>

<style scoped>
#to_top {
  position: fixed;
  bottom: 82px;
  right: 20px;
  border: #409EFF 1px solid;
  padding: 5px;
  border-radius: 5px;
}

#to_top:hover {
  background-color: #409EFF;
  color: white;
}
</style>